package concurrent.synchronized_;

public class Thread_Unsafe_Demo {

    private static int data = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread() {
            public void run() {
                for (int i = 0; i < 10; i++) {
                    Thread_Unsafe_Demo.data++;
                    System.out.println(data);
                }

            }
        };
        thread1.start();

        Thread thread2 = new Thread() {
            public void run() {
                for (int i = 0; i < 10; i++) {
                    Thread_Unsafe_Demo.data++;
                    System.out.println(data);
                }

            }
        };
        thread2.start();

        thread1.join();
        thread2.join();
    }
}
